<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单查询</title>
    <meta name="description" content="{:config('web_description')}">
    <meta name="keywords" content="{:config('web_keywords')}">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <link rel="shortcut icon" sizes="196x196" href="/assets/style3/images/logo.png">
    <link rel="stylesheet" href="/assets/common/font-awesome-4.6.3/css/font-awesome.min.css">
    <link rel="stylesheet"
          href="/assets/common/material-design-iconic-font-2.2.0/css/material-design-iconic-font.min.css">
    <link rel="stylesheet" href="/assets/common/animate.css">
    <link rel="stylesheet" href="/assets/common/bootstrap-3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" href="/assets/common/hamburgers/hamburgers.min.css">
    <link rel="stylesheet" href="/assets/style3/css/app.css">
    <script src="/assets/common/jquery-1.11.0.min.js"></script>
    <script src="/assets/common/layer-3.0.1/layer.js"></script>
    <link rel="stylesheet" type="text/css" href="/assets/common/sweetalert/sweetalert.css"/>
    <script src="/assets/common/sweetalert/sweetalert.min.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="/assets/common/switchery/switchery.min.css"/>
    <script src="/assets/common/switchery/switchery.min.js" type="text/javascript"></script>
</head>
<body class="simple-page">
<div id="back-to-home">
    <a href="/" class="btn btn-outline btn-default"><i class="fa fa-home animated zoomIn"></i></a>
</div>
<div class="simple-page-wrap">
    <div class="simple-page-logo animated swing">
        <a href="/">
            <span><i class="fa fa-gg"></i></span>
            <span>订单查询</span>
        </a>
    </div><!-- logo -->
    <div class="simple-page-form animated flipInY">
        <h4 class="form-title m-b-xl text-center">请输入QQ号查询订单</h4>
        <div class="form-group">
            <input type="text" class="form-control text-center" value="" id="qq" placeholder="输入QQ号查询订单~"
                   onKeyUp="value=value.replace(/[^1234567890-]+/g,'')" maxlength="11">
        </div>
        <a id="query" class="btn btn-primary">立即查询</a>
    </div><!-- #login-form -->

</div><!-- .simple-page-wrap -->
<script>
    $(document).ready(function () {
        $("#query").click(function () {
            var qq = $("#qq").val();
            var reg = /^[0-9]+$/;
            if (!qq) {
                swal({title: "请先输入QQ号码后再查询哦！", type: "warning"})
                return false;
            } else if (!reg.exec(qq)) {
                swal({title: "输入QQ号格式错误（只能数字哦）", type: "warning"})
                return false;
            } else if (qq.length < 5) {
                swal({title: "请输入正常的QQ号（5-10位数）", type: "warning"})
                return false;
            } else if (qq.length > 10) {
                swal({title: "请输入正常的QQ号（5-10位数）", type: "warning"})
                return false;
            } else {
                layer.load(0, 2);
                var url = "{:url('query')}";
                xiha.postData(url, "qq=" + qq, function (d) {
                    layer.closeAll('loading');
                    if (d.code == 1) {
                        location.href = "/index.php/index/index/qqinfo/uin/" + qq + ".html";
                    } else if (d.code == 2) {
                        swal({title: "这个QQ下没有任何订单哦~", type: "warning"})
                        return false;
                    } else {
                        swal({title: "非法操作！", type: "warning"})
                        return false;
                    }
                });
            }
        });
    });

    var xiha = {
        postData: function (url, parameter, callback, dataType, ajaxType) {
            if (!dataType) dataType = 'json';
            $.ajax({
                type: "POST",
                url: url,
                async: true,
                dataType: dataType,
                json: "callback",
                data: parameter,
                timeout: 10000, //超时时间设置，单位毫秒
                success: function (data) {
                    if (callback == null) {
                        return;
                    }
                    callback(data);
                },
                error: function (request, status, err) {
                    layer.closeAll('loading');
                    if (status == "timeout") {
                        swal({title: "请求超时，请重试！", type: "warning"});
                    } else {
                        swal({title: "链接失败，请重试！", type: "warning"});
                    }
                    return false;
                }
            });
        }
    }
</script>
</body>
</html>